import {
  Table,
  Column,
  Model,
  CreatedAt,
  UpdatedAt,
  ForeignKey,
  BelongsTo,
} from 'sequelize-typescript';
import { Project } from 'src/project/project.entity';
import { User } from 'src/user/user.entity';

@Table({
  tableName: 'video',
})
export class Video extends Model<Video> {
  @Column({
    primaryKey: true,
  })
  id: number;

  @Column
  uuid: string;

  @Column
  name: string;

  @Column
  introduction: string;

  @Column
  storage: string;

  @Column({ field: 'upload_time' })
  uploadTime: Date;

  @ForeignKey(() => User)
  @Column({ field: 'fk_user' })
  FKUser: number;

  @ForeignKey(() => Project)
  @Column({ field: 'fk_project' })
  FKAudit: number;

  @CreatedAt
  @Column({ field: 'created_at' })
  createdAt: Date;

  @UpdatedAt
  @Column({ field: 'updated_at' })
  updatedAt: Date;

  @BelongsTo(() => User)
  user: User;

  @BelongsTo(() => Project)
  project: Project;
}
